package org.jeecg.modules.demo.hd.controller;

import javax.servlet.http.HttpServletRequest;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.hd.entity.AppUserCashMain;
import org.jeecg.modules.demo.hd.service.*;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.demo.hd.vo.UserCashMainSearchInputVo;
import org.jeecg.modules.demo.hd.vo.UserCashMainViewVo;
import org.jeecg.modules.demo.hd.vo.myProject.CashOutVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @Description: 用户现金
 * @Author: jeecg-boot
 * @Date: 2025-02-04
 * @Version: V1.0
 */
@Api(tags = "用户现金")
@RestController
@RequestMapping("/hd/appUserCashMain")
@Slf4j
public class AppUserCashMainController extends JeecgController<AppUserCashMain, IAppUserCashMainService> {

    @Autowired
    private IAppUserCashMainService appUserCashMainService;

    /**
     * 分页列表查询
     *
     * @param appUserCashMain
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "app_user_cash_main-分页列表查询")
    @ApiOperation(value = "用户现金列表查询", notes = "用户现金列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<UserCashMainViewVo>> queryPageList(UserCashMainSearchInputVo appUserCashMain,
                                                           @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                           HttpServletRequest req) {
        Page<AppUserCashMain> page = new Page<AppUserCashMain>(pageNo, pageSize);
        IPage<UserCashMainViewVo> pageList = appUserCashMainService.getList(appUserCashMain,page);
        return Result.OK(pageList);
    }

    @ApiOperation(value = "查询用户账户余额", notes = "查询用户账户余额")
    @GetMapping(value = "/queryCurrentCash")
    public Result<Float> queryCurrentCash() {
        Float aFloat = appUserCashMainService.queryCurrentCash();
        return Result.OK(aFloat);
    }

    @ApiOperation(value = "人工提现", notes = "人工提现")
    @PostMapping(value = "/CashOut")
//    @RequiresPermissions("hd:usercash:cashout")
    public Result<String> CashOut(@RequestBody CashOutVo vo) {
        String s = appUserCashMainService.CashOut(vo);
        return Result.OK(s);
    }

    @ApiOperation(value = "获取所有待结清金额", notes = "获取所有待结清金额")
    @GetMapping(value = "/getTotalCash")
    public Result<Double> getTotalCash()
    {
        return Result.OK(0d);
    }
}
